package client;

import java.io.File;
import java.io.FileOutputStream;
import java.io.PrintWriter;
import java.util.List;

import entity.MatchedLogRec;
import exceptions.WriteDataException;

public class DataWriter {
	private String targetPath;
	public DataWriter(String targetPath) {
		this.targetPath=targetPath;
	}
	public void writeLogs(List<MatchedLogRec> matchedList) throws WriteDataException{
		try {
			File targetFile = new File(targetPath);
			FileOutputStream out = new FileOutputStream(targetFile,true);
			PrintWriter writer = new PrintWriter(out,true);
			for (MatchedLogRec rec : matchedList) {
				writer.println(rec);
			}
			out.close();
			writer.close();
		} catch (Exception e) {
			e.printStackTrace();
			throw new WriteDataException(e);
		}
	}
}
